# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


# useful for handling different item types with a single interface
from itemadapter import ItemAdapter
import pymysql

class HuyaPipeline:
    def open_spider(self,spider):
        self.con = pymysql.connect(host='10.30.59.136',port=3306,user='root',password='123456',database='wdr',charset='utf8')
        self.cur = self.con.cursor()
    def close(self,spider):
        self.con.close()
        self.cur.close()
    def process_item(self, item, spider):
        self.cur.execute('insert into huya_copy1_copy(Type_name,sudu,name,qi,dy) values(%s,%s,%s,%s,%s)',[item['Type_name'],item['sudu'],item['name'],item['qi'],item['dy']])
        self.con.commit()
        return item
